@import '../../style/themes/default';
@import '../../style/mixins/index';

@menu-prefix-cls: ~'@{c7n-prefix}-menu';

// default theme
.@{menu-prefix-cls} {
  .reset-component;
  margin-bottom: 0;
  padding-left: 0; // Override default ul/ol
  color: @menu-item-color;
  line-height: 0; // Fix display inline-block gap
  list-style: none;
  background: @menu-bg;
  outline: none;
  box-shadow: @box-shadow-base;
  transition: background @animation-duration-slow, width @animation-duration-base;
  .clearfix;

  ul,
  ol {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  &-hidden {
    display: none;
  }

  &-item-group-title {
    padding: 0.08rem 0.16rem;
    color: @menu-item-group-title-color;
    font-size: @font-size-base;
    line-height: @line-height-base;
    transition: all @animation-duration-slow;
  }

  &-submenu,
  &-submenu-inline {
    transition: border-color @animation-duration-slow @ease-in-out, background @animation-duration-slow @ease-in-out,
      padding 0.15s @ease-in-out;
  }

  // &-item:active,
  // &-submenu-title:active {
  //   background: @menu-item-active-bg;
  // }

  &-submenu &-sub {
    cursor: initial;
    transition: background @animation-duration-slow @ease-in-out, padding @animation-duration-slow @ease-in-out;
  }

  &-item > a {
    color: @menu-item-color;
    &:focus {
      text-decoration: none;
    }
    &::before {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      background-color: transparent;
      content: '';
    }
    > span {
      display: inline-block;
    }
  }

  &-item-divider {
    height: 0.01rem;
    overflow: hidden;
    line-height: 0;
    background-color: @border-color-split;
  }

  &-item:hover,
  &-item-active,
  &:not(&-inline) &-submenu-open,
  &-submenu-active,
  &-submenu-title:hover {
    background-color: @item-hover-bg;
  }

  &-horizontal &-item,
  &-horizontal &-submenu {
    margin-top: -0.01rem;
  }

  &-horizontal > &-item:hover,
  &-horizontal > &-item-active,
  &-horizontal > &-submenu &-submenu-title:hover {
    background-color: transparent;
  }

  &-item-selected {
    color: @menu-highlight-color;
    > a,
    > a:hover {
      color: @menu-highlight-color;
    }
  }

  &:not(&-horizontal) &-item-selected {
    background-color: @menu-item-active-bg;
    &:hover {
      background-color: @item-hover-bg;
    }
  }

  &-inline,
  &-vertical,
  &-vertical-left {
    border-right: @border-width-base @border-style-base @border-color-split;
  }
  &-vertical-right {
    border-left: @border-width-base @border-style-base @border-color-split;
  }

  &-vertical&-sub,
  &-vertical-left&-sub,
  &-vertical-right&-sub {
    padding: 0;
    border-right: 0;
    transform-origin: 0 0;
    .@{menu-prefix-cls}-item {
      left: 0;
      margin-left: 0;
      border-right: 0;
      &::after {
        border-right: 0;
      }
    }
    > .@{menu-prefix-cls}-item,
    > .@{menu-prefix-cls}-submenu {
      transform-origin: 0 0;
    }
  }

  &-horizontal&-sub,
  &-vertical&-sub,
  &-vertical-left&-sub,
  &-vertical-right&-sub {
    min-width: 1.6rem;
  }

  &-item,
  &-submenu-title {
    position: relative;
    display: block;
    margin: 0;
    padding: 0 0.2rem;
    white-space: nowrap;
    cursor: pointer;
    transition: color @animation-duration-slow @ease-in-out, border-color @animation-duration-slow @ease-in-out,
      background @animation-duration-slow @ease-in-out, padding 0.15s @ease-in-out;
    .@{iconfont-css-prefix} {
      min-width: 0.14rem;
      margin-right: 0.1rem;
      line-height: inherit;
      vertical-align: top;
      transition: font-size 0.15s @ease-out, margin @animation-duration-slow @ease-in-out;
      + span {
        display: inline-block;
        opacity: 1;
        transition: opacity @animation-duration-slow @ease-in-out, width @animation-duration-slow @ease-in-out;
      }
    }
  }

  & > &-item-divider {
    height: 0.01rem;
    margin: 0.01rem 0;
    padding: 0;
    overflow: hidden;
    line-height: 0;
    background-color: @border-color-split;
  }

  &-submenu {
    &-popup {
      position: absolute;
      z-index: @zindex-dropdown;
      border-radius: @border-radius-base;
    }

    > .@{menu-prefix-cls} {
      background-color: @menu-bg;
      border-radius: @border-radius-base;
      &-submenu-title::after {
        transition: transform @animation-duration-slow @ease-in-out;
      }
    }

    &-vertical,
    &-vertical-left,
    &-vertical-right,
    &-inline {
      > .@{menu-prefix-cls}-submenu-title .@{menu-prefix-cls}-submenu-arrow {
        position: absolute;
        top: 50%;
        right: 0.16rem;
        width: 0.1rem;
        transition: transform @animation-duration-slow @ease-in-out;
        &::before,
        &::after {
          position: absolute;
          width: 0.06rem;
          height: 0.015rem;
          vertical-align: baseline;
          background: #fff;
          background-image: linear-gradient(to right, @menu-item-color, @menu-item-color);
          border-radius: 0.02rem;
          transition: background @animation-duration-slow @ease-in-out, transform @animation-duration-slow @ease-in-out,
            top @animation-duration-slow @ease-in-out;
          content: '';
        }
        &::before {
          transform: rotate(45deg) translateY(-0.02rem);
        }
        &::after {
          transform: rotate(-45deg) translateY(0.02rem);
        }
      }
    }

    &-inline > .@{menu-prefix-cls}-submenu-title .@{menu-prefix-cls}-submenu-arrow {
      &::before {
        transform: rotate(-45deg) translateX(0.02rem);
      }
      &::after {
        transform: rotate(45deg) translateX(-0.02rem);
      }
    }

    &-open {
      &.@{menu-prefix-cls}-submenu-inline
        > .@{menu-prefix-cls}-submenu-title
        .@{menu-prefix-cls}-submenu-arrow {
        transform: translateY(-0.02rem);
        &::after {
          transform: rotate(-45deg) translateX(-0.02rem);
        }
        &::before {
          transform: rotate(45deg) translateX(0.02rem);
        }
      }
      &-submenu-title {
        color: @menu-highlight-color;
      }
    }
  }

  &-vertical &-submenu-selected,
  &-vertical-left &-submenu-selected,
  &-vertical-right &-submenu-selected {
    color: @menu-highlight-color;
    background-color: @item-active-bg;
    > a {
      color: @menu-highlight-color;
    }
  }

  &-horizontal {
    line-height: 0.46rem;
    border: 0;
    border-bottom: @border-width-base @border-style-base @border-color-split;
    box-shadow: none;

    > .@{menu-prefix-cls}-item,
    > .@{menu-prefix-cls}-submenu {
      position: relative;
      top: 0.01rem;
      float: left;
      border-bottom: 0.02rem solid transparent;

      &:hover,
      &-active,
      &-open,
      &-selected {
        color: @menu-highlight-color;
        border-bottom: 0.02rem solid @menu-highlight-color;
      }

      > a {
        display: block;
        color: @menu-item-color;
        &:hover {
          color: @menu-highlight-color;
        }
        &::before {
          bottom: -0.02rem;
        }
        > span {
          display: inline-block;
        }
      }
    }

    &::after {
      display: block;
      clear: both;
      height: 0;
      content: '\20';
    }
  }

  &-vertical,
  &-vertical-left,
  &-vertical-right,
  &-inline {
    .@{menu-prefix-cls}-item {
      position: relative;
    }

    .@{menu-prefix-cls}-item,
    .@{menu-prefix-cls}-submenu-title {
      height: @menu-item-height;
      padding: 0 0.16rem;
      overflow: hidden;
      font-size: @font-size-base;
      line-height: @menu-item-height;
      text-overflow: ellipsis;
    }

    // disable margin collapsed
    .@{menu-prefix-cls}-submenu {
      padding-bottom: 0.0001rem;
    }

    > .@{menu-prefix-cls}-item,
    > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
      height: @menu-inline-toplevel-item-height;
      line-height: @menu-inline-toplevel-item-height;
    }
  }

  &-inline {
    width: 100%;

    .@{menu-prefix-cls}-item,
    .@{menu-prefix-cls}-submenu-title {
      width: ~'calc(100% + .01rem)';
    }

    .@{menu-prefix-cls}-submenu-title {
      padding-right: 0.34rem;
    }
  }

  &-inline-collapsed {
    width: @menu-collapsed-width;
    > .@{menu-prefix-cls}-item,
    > .@{menu-prefix-cls}-item-group
      > .@{menu-prefix-cls}-item-group-list
      > .@{menu-prefix-cls}-item,
    > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
      left: 0;
      padding: 0 (@menu-collapsed-width - 0.16rem) / 2 !important;
      text-overflow: clip;
      .@{menu-prefix-cls}-submenu-arrow {
        display: none;
      }
      .@{iconfont-css-prefix} {
        margin: 0;
        font-size: 0.16rem;
        line-height: @menu-item-height;
        + span {
          display: inline-block;
          max-width: 0;
          opacity: 0;
        }
      }
    }
    &-tooltip {
      pointer-events: none;
      .@{iconfont-css-prefix} {
        display: none;
      }
      a {
        color: @text-color-dark;
      }
    }

    .@{menu-prefix-cls}-item-group-title {
      padding-right: 0.04rem;
      padding-left: 0.04rem;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }

  &-item-group-list {
    margin: 0;
    padding: 0;
    .@{menu-prefix-cls}-item,
    .@{menu-prefix-cls}-submenu-title {
      padding: 0 0.16rem 0 0.28rem;
    }
  }

  &-root&-vertical,
  &-root&-vertical-left,
  &-root&-vertical-right,
  &-root&-inline {
    box-shadow: none;
  }

  &-sub&-inline {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    & > .@{menu-prefix-cls}-item,
    & > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
      height: @menu-item-height;
      line-height: @menu-item-height;
      list-style-position: inside;
      list-style-type: disc;
    }

    & .@{menu-prefix-cls}-item-group-title {
      padding-left: 0.32rem;
    }
  }

  // Disabled state sets text to gray and nukes hover/tab effects
  &-item-disabled,
  &-submenu-disabled {
    color: @disabled-color !important;
    background: none;
    border-color: transparent !important;
    cursor: not-allowed;
    > a {
      color: @disabled-color !important;
      pointer-events: none;
    }
    > .@{menu-prefix-cls}-submenu-title {
      color: @disabled-color !important;
      cursor: not-allowed;
    }
  }
}

@import './dark';
